#include <cstdio>

int main()
{
	freopen("compress.in",  "r", stdin);
	freopen("compress.out", "w", stdout);
	int n = 0;
	scanf("%d", &n);
	printf("%d ", n);
	int d = 0;
	int stepData = 0, dataCnt = 0;
	for ( int i = 0; i < n * n; i++ )
	{
		scanf("%d", &d);
		if ( stepData == d ) {
			dataCnt ++;
		}
		else {
			stepData = stepData == 1 ? 0 : 1;
			printf("%d ", dataCnt);
			dataCnt = 1;
		}
	}
	printf("%d ", dataCnt);
	fclose(stdin);
	fclose(stdout);
	return 0;
} 
